{% extends 'admin/extende/base.html' %}

{% block title %}
<title>商品修改</title>
{% endblock %}


{% block context %}
    <div class="container-fluid am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span>商品添加</div>
            </div>
        </div>
    </div>
    <div class="row">

        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-body am-fr">

                    <form action="{% url 'admin_goods_upinsert' %}" method="post" enctype="multipart/form-data" class="am-form tpl-form-border-form tpl-form-border-br">
                        {% csrf_token %}
                        <input type="hidden" name="uid" value="{{ data.id }}">
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品名</label>
                            <div class="am-u-sm-9">
                                <input name="title" value="{{ data.title }}" type="text" class="tpl-form-input" id="user-name" required>
                                <small>请输入商品名称。</small>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品价格 </label>
                            <div class="am-u-sm-9">
                                <input name="price" value="{{ data.price }}"  type="text" class="tpl-form-input" id="user-name" required>
                                <small>请输入商品价格</small>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">库存 </label>
                            <div class="am-u-sm-9">
                                <input name="num" value="{{ data.num }}" type="number" class="tpl-form-input" id="user-name" >
                                <small>请输入商品库存。</small>
                            </div>
                        </div>



                        <div class="am-form-group">
                               <label for="user-name" class="am-u-sm-3 am-form-label">
                                商品状态
                                </label>
                               <div class="am-u-sm-9">
                                <select name="status" data-am-selected="">
                                    <option value="0" {% if data.status == 0 %} selected {% endif %}>新发布</option>
                                    <option value="1" {% if data.status == 1 %} selected {% endif %}>热卖</option>
                                </select>
                               </div>
                        </div>


                        <link rel="stylesheet" type="text/css" href="/ueditor/UE/third-party/SyntaxHighlighter/shCoreDefault.css">
                        <script type="text/javascript" src="/ueditor/UE/third-party/SyntaxHighlighter/shCore.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.config.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.all.min.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/lang/zh-cn/zh-cn.js"></script>
                        <div class="am-form-group">
                            <label for="user-intro" class="am-u-sm-3 am-form-label">文章内容</label>
                            <div class="am-u-sm-9">
{#                                <textarea class="" rows="10" id="user-intro" placeholder="请输入文章内容"></textarea>#}
                                  <script  id="editor" name="info" type="text/plain" style="height:500px;color: black">

                                  </script>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-weibo" class="am-u-sm-3 am-form-label">上传商品图片 </label>
                            <div class="am-u-sm-9">
                                <div id="upimg" class="am-form-group am-form-file">
                                    <div class="tpl-form-file-img" id="showimg">
                                        <img src="{{ data.pic }} " alt="" width="100">
                                    </div>
                                    <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                        <i class="am-icon-cloud-upload"></i> 点击上传
                                    </button>
                                    <input name="pic" id="doc-form-file" type="file" multiple="">
                                </div>

                            </div>
                        </div>
                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
<script type="text/javascript">
        var ue = UE.getEditor('editor');
        SyntaxHighlighter.all();
        {#//对编辑器的操作最好在编辑器ready之后再做#}
        ue.ready(function() {
        {#//设置编辑器的内容#}
        ue.setContent('{{ data.info }}');
        {#//获取纯文本内容，返回: hello#}
        var txt = ue.getContentTxt();
        ue.setContent(txt);
        });
</script>

{% endblock %}

{% block jq %}

    <script>
        $("#doc-form-file").uploadView({
        uploadBox: '#upimg',//设置上传框容器
        showBox : '#showimg',//设置显示预览图片的容器
        width : 100, //预览图片的宽度，单位px
        height : 100, //预览图片的高度，单位px
        allowType: ["gif", "jpeg", "jpg", "bmp", "png"], //允许上传图片的类型
        maxSize :2, //允许上传图片的最大尺寸，单位M
        success:function(e){
            $(".js_uploadText").text('更改');
        }
    });
    </script>
{% endblock %}
